package com.monitor.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.monitor.service.MonitorService;

@Controller
@RequestMapping("/monitor")
public class MonitorController{
	@Resource(name="monitorService")
	private MonitorService monitorService;
	/**
	 * 单机一般耗能设备实时刷新
	 * @param equId
	 * @param response
	 * @return
	 */
	@RequestMapping("/singlerefresh")
	public Map<String, Object> singleRefreshData(@RequestParam(value="equId",required=false,defaultValue="0")int equId,
			HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		Map<String, Object> model=new HashMap<String, Object>();
		monitorService.singleRefreshData(equId, model);
		return model;
	}
	
	/**
	 * 整线设备实时刷新
	 * @param lineId
	 * @param response
	 * @return
	 */
	@RequestMapping("/linerefresh")
	public Map<String, Object> lineRefreshData(@RequestParam(value="lineId",required=false,defaultValue="0")int lineId,
			HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		Map<String, Object> model=new HashMap<String, Object>();
		monitorService.lineRefreshData(lineId, model);
		return model;
	}
	
	/**
	 * 单机重点耗能设备实时刷新
	 * @param equId
	 * @param response
	 * @return
	 */
	@RequestMapping("/highEnergSingle")
	public Map<String, Object> highEnergSingle(@RequestParam(value="equId",required=false,defaultValue="0")int equId,
			HttpServletResponse response) {
		response.setHeader("Access-Control-Allow-Origin", "*");
		Map<String, Object> model=new HashMap<String, Object>();
		monitorService.highEnergSingle(equId, model);
		return model;
	}
	
}
